<?php
namespace app\common\validate\tysj;

class Corporation extends Base {
    /**
     * 验证规则
     */
    protected $rule = [
        'lock'                => 'require',
        'id'                  => 'require',
        'uid'                 => 'require',
        'sid'                 => 'require',
        'id_card_front_image' => 'require|max:100',
        'id_card_back_image'  => 'require|max:100',
        'name'                => 'require|max:32',
        'id_card_no'          => 'require|idCard',
        'id_card_start_date'  => 'require|date:Y-m-d',
        'id_card_end_date'    => 'require|date:Y-m-d|checkEndDate:id_card_start_date'
    ];


    /**
     * 提示消息
     */
    protected $message = [
        'lock.require'                  => '验证规则场景不存在',
        'id.require'                    => '法人信息ID不能为空',
        'id.lock'                       => '禁止直接编辑该数据',
        'uid.require'                   => '用户ID不能为空',
        'sid.require'                   => '店铺ID不能为空',
        'sid.isUser'                    => '店铺不属于您',
        'sid.unique'                    => '法人信息已经填写',
        'sid.isShow'                    => '店铺暂未开张',
        'id_card_front_image.require'   => '身份证正面照地址不能为空',
        'id_card_front_image.max'       => '身份证正面照地址不能超过100个字符',
        'id_card_back_image.require'    => '身份证背面照不能为空',
        'id_card_back_image.max'        => '身份证背面照不能超过100个字符',
        'name.require'                  => '法人姓名不能为空',
        'name.max'                      => '法人姓名不能超过32个字符',
        'id_card_no.require'            => '身份证号码不能为空',
        'id_card_no.idCard'             => '身份证号码不合法',
        'id_card_start_date.require'    => '身份证开始日期不能为空',
        'id_card_start_date.date'       => '身份证开始日期不合法',
        'id_card_end_date.require'      => '身份证结束日期不能为空',
        'id_card_end_date.date'         => '身份证结束日期不合法',
        'id_card_end_date.checkEndDate' => '身份证结束日期必须大于开始日期'
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'save'        => [
            'uid', 
            'sid' => 'require|unique:app\common\model\tysj\Corporation|isUser:tysj\Store', 
            'id_card_front_image', 
            'id_card_back_image', 
            'name', 
            'id_card_no',
            'id_card_start_date',
            'id_card_end_date'
        ],
        'look'        => ['sid' => 'require|isShow:tysj\Store'],
        'info'        => ['sid' => 'require|isUser:tysj\Store']
    ];
}